AddCSLuaFile( "cl_init.lua" ) -- Make sure clientside
AddCSLuaFile( "shared.lua" )  -- and shared scripts are sent.
 
include('shared.lua')
 
function ENT:Initialize()
 
	self:SetModel( INV_BARRIERMODEL )
	self:PhysicsInit( SOLID_VPHYSICS )
	self:SetMoveType( MOVETYPE_NONE )
	self:SetSolid( SOLID_VPHYSICS )
	self:SetColor( 0, 255, 0, 255 )
	self:SetHealth(INV_BARRIERHEALTH)
	
	-- Physics is never enabled on this...
	local phys = self:GetPhysicsObject()
	if phys:IsValid() then
		phys:EnableMotion(false)
	end
end
 
function ENT:Use( activator, caller )
    return
end

function ENT:OnTakeDamage( dmg )

	self:SetHealth(self:Health() - dmg:GetDamage())
	
	-- Scale from green to red...
	local greenmult = self:Health() / INV_BARRIERHEALTH
	local redmult = (self:Health() / INV_BARRIERHEALTH)
	redmult = -redmult + 1
	
	self:SetColor( 255 * redmult, 255 * greenmult, 0, 255 )
	
	if(self:Health() <= 0)then
		self:Remove()
	end
end

function ENT:Think()
end
